#include "pm/project.h"

using namespace pm;

const wxString Project::TABLE_NAME   = wxT("projects");

Project::Project()
: db::Table()
{
}

Project::Project(wxSQLite3ResultSet& res)
: db::Table(res)
, name(res, wxT("name"))
{
}

db::update_value_t Project::prepare_insert(wxSQLite3Database& db)
{
	wxSQLite3Statement stmt = db.PrepareStatement("insert into projects values(null, ?)");
	stmt.Bind(1, name());
	return db::update_value_t(true, stmt);
}

db::update_value_t Project::prepare_update(wxSQLite3Database& db)
{
	wxSQLite3Statement stmt = db.PrepareStatement("update projects set name = ? where id = ?");
	stmt.Bind(1, name());
	stmt.Bind(2, id());
	return db::update_value_t(true, stmt);}
